import React from 'react'
import { useNavigate, useLocation } from 'umi'
export default function index() {
  const navigate = useNavigate();
  const location = useLocation();
  const userLogin = () => {
    setTimeout(() => {
      alert('登录成功');
      localStorage.setItem('token', 'defrgthy')
      // navigate('/home')
      if(location.state){
        navigate(location.state.from.pathname)
      }else{
        navigate('/home')
      }
    }, 2000)
  }
  return (
    <div>
      <h2>登录页</h2>
      <button onClick = {
        userLogin
      }>登录</button>
    </div>
  )
}
